

package com.hexinfo.dmpro.sparing.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hexinfo.dmpro.common.annotation.AnonymousAccess;
import org.apache.ibatis.annotations.Param;
import org.springframework.http.ResponseEntity;
import com.hexinfo.dmpro.sparing.model.ScanMetadataWguat;
import com.hexinfo.dmpro.sparing.service.ScanMetadataWguatService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletResponse;


/**
 * 万国UAT元数据扫描表
 *
 * @author yemw
 * @date 2023-10-09 11:15:32
 */
@RestController
@AllArgsConstructor
@RequestMapping("/api/scanmetadatawguat" )
@Api(value = "scanmetadatawguat", tags = "万国UAT元数据扫描表管理")
public class ScanMetadataWguatController {

    private final  ScanMetadataWguatService scanMetadataWguatService;

    /**
     * 分页查询
     * @param page 分页对象
     * @param scanMetadataWguat 万国UAT元数据扫描表
     * WrapperEnhancer.like(scanMetadataWguat); //自动拼接存在值sql的方法
     * @return
     */
    @ApiOperation(value = "分页查询", notes = "分页查询")
    @GetMapping("/page" )
    @AnonymousAccess
    public ResponseEntity<Object> getScanMetadataWguatPage(Page page, ScanMetadataWguat scanMetadataWguat) {
        return ResponseEntity.ok(scanMetadataWguatService.queryList(page,scanMetadataWguat));
    }


    /**
     * 通过id查询万国UAT元数据扫描表
     * @param id id
     * @return R
     */
    @ApiOperation(value = "通过id查询", notes = "通过id查询")
    @GetMapping("/{id}" )
    public ResponseEntity<Object> getById(@PathVariable("id" ) String id) {
        return ResponseEntity.ok(scanMetadataWguatService.getById(id));
    }

    /**
     * 新增万国UAT元数据扫描表
     * @param scanMetadataWguat 万国UAT元数据扫描表
     * @return R
     */
    @ApiOperation(value = "新增万国UAT元数据扫描表", notes = "新增万国UAT元数据扫描表")
    @PostMapping
    public ResponseEntity<Object> save(@RequestBody ScanMetadataWguat scanMetadataWguat) {
        return ResponseEntity.ok(scanMetadataWguatService.save(scanMetadataWguat));
    }

    /**
     * 修改万国UAT元数据扫描表
     * @param scanMetadataWguat 万国UAT元数据扫描表
     * @return R
     */
    @ApiOperation(value = "修改万国UAT元数据扫描表", notes = "修改万国UAT元数据扫描表")
    @PutMapping
    public ResponseEntity<Object> updateById(@RequestBody ScanMetadataWguat scanMetadataWguat) {
        return ResponseEntity.ok(scanMetadataWguatService.updateById(scanMetadataWguat));
    }

    /**
     * 通过id删除万国UAT元数据扫描表
     * @param id id
     * @return R
     */
    @ApiOperation(value = "通过id删除万国UAT元数据扫描表", notes = "通过id删除万国UAT元数据扫描表")
    @DeleteMapping("/{id}" )
    public ResponseEntity<Object> removeById(@PathVariable String id) {
        return ResponseEntity.ok(scanMetadataWguatService.removeById(id));
    }


    /**
     * 读取UATexcel文档
     * @param
     * @return
     */
    @ApiOperation(value = "读取UATexcel文档", notes = "读取UATexcel文档")
    @PostMapping("/readExcel")
    @AnonymousAccess
    public ResponseEntity<Object> readExcel(@RequestParam("file") MultipartFile file) throws Exception{
        return ResponseEntity.ok(scanMetadataWguatService.testSync(file));
    }


    /**
     * 下载UAT模板
     * @param
     * @return
     */
    @ApiOperation(value = "下载UAT模板", notes = "下载UAT模板")
    @GetMapping("/getFiles")
    @AnonymousAccess
    public void getFiles(@Param("flag") String flag, HttpServletResponse response){
        scanMetadataWguatService.getFiles(flag,response);
    }
}
